from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from configs import dburl
import pymysql
pymysql.install_as_MySQLdb()

app = Flask(__name__)
# 配置数据库的连接参数
#######################################cfg
app.config['SQLALCHEMY_DATABASE_URI'] = dburl
#######################################
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)

app.app_context().push()

class Study_id(db.Model):
    __tablename__ = 'study_id'

    id = db.Column(db.Integer, primary_key=True)
    study_id = db.Column(db.String(255, 'utf8_general_ci'), unique=True,info='dicom study instance uid')
    orthanc_id = db.Column(db.String(255, 'utf8_general_ci'), info='orthanc study id')

    def __init__(self,study_id,orthanc_id):
        self.study_id = study_id
        self.orthanc_id = orthanc_id
         
if __name__ == '__main__':
    db.drop_all()        
    db.create_all()
